package com.ysqcould.web.controller.activity;


import com.ysqcould.activity.domain.ActivityApplyCustom;
import com.ysqcould.activity.service.IActivityApplyCustomService;
import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 活动报名展示自定字段Controller
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/activity/custom")
public class ActivityApplyCustomController extends BaseController
{
    @Autowired
    private IActivityApplyCustomService activityApplyCustomService;

    /**
     * 查询活动报名展示自定字段列表
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityApplyCustom activityApplyCustom)
    {
        startPage();
        List<ActivityApplyCustom> list = activityApplyCustomService.selectActivityApplyCustomList(activityApplyCustom);
        return getDataTable(list);
    }

    /**
     * 导出活动报名展示自定字段列表
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:export')")
    @Log(title = "活动报名展示自定字段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityApplyCustom activityApplyCustom)
    {
        List<ActivityApplyCustom> list = activityApplyCustomService.selectActivityApplyCustomList(activityApplyCustom);
        ExcelUtil<ActivityApplyCustom> util = new ExcelUtil<ActivityApplyCustom>(ActivityApplyCustom.class);
        util.exportExcel(response, list, "活动报名展示自定字段数据");
    }

    /**
     * 获取活动报名展示自定字段详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(activityApplyCustomService.selectActivityApplyCustomById(id));
    }

    /**
     * 新增活动报名展示自定字段
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:add')")
    @Log(title = "活动报名展示自定字段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityApplyCustom activityApplyCustom)
    {
        return toAjax(activityApplyCustomService.insertActivityApplyCustom(activityApplyCustom));
    }

    /**
     * 修改活动报名展示自定字段
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:edit')")
    @Log(title = "活动报名展示自定字段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityApplyCustom activityApplyCustom)
    {
        return toAjax(activityApplyCustomService.updateActivityApplyCustom(activityApplyCustom));
    }

    /**
     * 删除活动报名展示自定字段
     */
    @PreAuthorize("@ss.hasPermi('activity:custom:remove')")
    @Log(title = "活动报名展示自定字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityApplyCustomService.deleteActivityApplyCustomByIds(ids));
    }
}
